/*
 * tcp_new_tcpcb.c
 *
 *  Created on: 2009-5-20
 *      Author: tian
 */
#include"mytcp.h"

struct tcpcb* tcp_new_tcpcb(pid_t pid,int sock,int state,struct sockaddr *psockaddr,int msgqid){
	struct tcpcb *p;
	p=malloc(sizeof(struct tcpcb));
	memset(p,0,sizeof(struct tcpcb));
	if(p==NULL){
		fprintf(stderr,"cannot malloc tcpcb\n");
		return NULL;
	}
	p->msgqid=msgqid;
	p->pid=pid;
	p->sock=sock;
	p->tcp_state=state;
	if(psockaddr!=NULL)
		p->sock_addr=*psockaddr;
	p->seq=rand();
	//list should be paid attention to
	//if(head==NULL)
		p->next=head;
	//else
		//p->next=head->next;
	head=p;
	return p;
}
